/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package group2assignone.ucm.manager;

import group2assignone.dao.MyDAO;
import group2assignone.model.Airport;
import group2assignone.ucm.UCController;
import group2assignone.ucm.UCStartup;
import group2assignone.view.manager.EditAirportView;
import group2assignone.view.manager.ManagerView;

/**
 * Use Case: Confirm new airport details                                    <br>
 * Pre-condition: User clicks the 'done' button from edit airport view     .<br>
 * Post-condition: Manager main UI is displayed                 .           <br>
 * 1. system exits the current view                                         <br>
 * 2. system Retrieves the new airport details                              <br>
 * 3. system writes the data to the databse                                 <br>
 * 4. system restores Manager main view                                      <br>

 * @author group2
 */
public class UCEditAirportDone implements UCController
{
    private EditAirportView view;

    public UCEditAirportDone(EditAirportView view)
    {
        this.view = view;
    }

    public void run()
    {
        //1. system exits the current view
        view.dispose();

        //2. system Retrieves the new airport details
        Airport airport = new Airport();
        view.loadDetails(airport);
        String oldAirportLoc = view.getOldAirportLoc();
        //3. system writes the data to the databse
        MyDAO coms = UCStartup.getInstance().getDAO();
        coms.sQLEditAirport(airport, oldAirportLoc);

         // 4. system restores Manager main view                               <br>
        ManagerView manView = ManagerView.getInstance();
        manView.go();

    }
}
